package cn.xhy.material.dal.mysql.commodityinfo;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.xhy.material.controller.admin.commodityinfo.vo.CommodityInfoPageReqVO;
import cn.xhy.material.dal.dataobject.commodityinfo.CommodityInfoDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * 商品信息 Mapper
 *
 * @author xhy
 */
@Mapper
public interface CommodityInfoMapper extends BaseMapperX<CommodityInfoDO> {

    default PageResult<CommodityInfoDO> selectPage(CommodityInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommodityInfoDO>()
                .eqIfPresent(CommodityInfoDO::getSonId, reqVO.getSonId())
                .eqIfPresent(CommodityInfoDO::getBarCode, reqVO.getBarCode())
                .eqIfPresent(CommodityInfoDO::getProductType, reqVO.getProductType())
                .eqIfPresent(CommodityInfoDO::getCategory, reqVO.getCategory())
                .likeIfPresent(CommodityInfoDO::getGname, reqVO.getGname())
                .eqIfPresent(CommodityInfoDO::getModel, reqVO.getModel())
                .eqIfPresent(CommodityInfoDO::getBrand, reqVO.getBrand())
                .eqIfPresent(CommodityInfoDO::getUnit, reqVO.getUnit())
                .eqIfPresent(CommodityInfoDO::getStats, reqVO.getStats())
                .eqIfPresent(CommodityInfoDO::getType, reqVO.getType())
                .eqIfPresent(CommodityInfoDO::getIsBatchnumber, reqVO.getIsBatchnumber())
                .eqIfPresent(CommodityInfoDO::getDepict, reqVO.getDepict())
                .eqIfPresent(CommodityInfoDO::getSpecif, reqVO.getSpecif())
                .eqIfPresent(CommodityInfoDO::getIsSplit, reqVO.getIsSplit())
                .betweenIfPresent(CommodityInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CommodityInfoDO::getId));
    }

}
